package logic

import (
	"woanju/dao/mysql"
	"woanju/models"
	snowflake "woanju/pkg/snowflask"
)

func InsertEquipment(e *models.Equipment) error {
	e.EquipmentID = snowflake.GenID()
	return mysql.InsertEquipment(e)
}

func DeleteEquipment(eid int64) error {
	return mysql.DeleteEquipment(eid)
}

func UpdateEquipmentStatus(p *models.ParamEquipmentStatus) error {
	return mysql.UpdateEquipmentStatus(p)
}

func GetEquipmentList(uid int64) ([]*models.Equipment, error) {
	data1, err := mysql.GetEquipmentListOrderOne(uid)
	if err != nil {
		return nil, err
	}
	data2, err := mysql.GetEquipmentListOrderTwo(uid)
	if err != nil {
		return nil, err
	}
	result := append(data1, data2...)
	return result, nil
}
